package net.kehk.towerdefense.gamelogic;

public class Projectile extends DrawableEntity{

	Enemy target;
	float target_x;
	float target_y;

	/**
	 * 
	 * Génère un projectile autoguidé vers sa cible
	 * 
	 * @param pos_x Position x initiale du projectile
	 * @param pos_y Position y initiale du projectile
	 * @param velocity Vitesse du projectile
	 * @param width Largeur du projectile
	 * @param height Hauteur du projectile
	 * @param e Cible
	 */
	public Projectile(float pos_x, float pos_y, float velocity, int width, int height, Enemy target){
		super(pos_x, pos_y, velocity, width, height);
		this.target=target;
	}

	public Projectile(float pos_x, float pos_y, float velocity, int width, int height, float target_x, float target_y){
		this(pos_x, pos_y, velocity, width, height, null);
		this.target_x=target_x;
		this.target_y=target_y;
	}

	public void update(){
		if(target!=null){
			this.move(target.getHitbox().x, target.getHitbox().y);
		}
		else{
			this.move(target_x, target_y);
		}
	}
}
